package twentytwenty;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-04 14:46
 * @Modified By:
 */
public class SingleNumber_136 {
    public static void main(String [] args){
        int [] nums = new int[]{2,2,2,1,3,3};
        System.out.println(singleNumber(nums));
    }

    public static int singleNumber(int[] nums) {
        int change;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == Integer.MAX_VALUE){
                continue;
            }
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] == nums[j]){
                    change = nums[i];
                    for (int k = 0; k < nums.length; k++) {
                        if (nums[k] == change){
                            nums[k] = Integer.MAX_VALUE;
                        }
                    }
                    break;
                }
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != Integer.MAX_VALUE){
                return nums[i];
            }
        }
        return nums[1];
    }
}
